const address = require('../models/address')

// 添加address
const addAddress = async (ctx) => {
  const data = ctx.request.body
  const result = await address.addAddress(data)
  if(result) {
    ctx.body = {
      code: 0,
      message: '成功'
    }
  }else {
    ctx.body = {
      code: -1,
      message: '失败'
    }
  }
}

// 根据address_detail_id获取地址
const getAddress = async (ctx) => {
  const id = ctx.params.id
  const data = await address.getAddress(id)
  if(data) {
    ctx.body = {
      code: 0,
      data,
      message: '成功'
    }
  }else {
    ctx.body = {
      code: -1,
      message: '失败'
    }
  }
}
module.exports = {
  addAddress,
  getAddress
}